package cn.dankal.lequ.ui.fragment.buluo_fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import cn.dankal.lequ.R;
import cn.dankal.lequ.commom.adapter.BaseAdapter.ViewHolder;
import cn.dankal.lequ.commom.adapter.BaseAdapter.recyclerview.CommonAdapter;
import cn.dankal.lequ.ui.activity.PostBarActivity;

/**
 * Created by Dankal on 16/4/26.
 */
public class HuatiFragment extends Fragment {
    @Bind(R.id.recyclerview)
    RecyclerView recyclerview;
    LinearLayoutManager linearLayoutManager;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_buluo_huati, container, false);
        ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initRecyclerView();
    }

    private void initRecyclerView() {
        linearLayoutManager = new LinearLayoutManager(getActivity());
        recyclerview.setLayoutManager(linearLayoutManager);
        recyclerview.setHasFixedSize(true);
        List<Integer> mDatas = new ArrayList<>();
        mDatas.add(1);
        mDatas.add(2);
        mDatas.add(3);
        mDatas.add(4);
        recyclerview.setAdapter(new CommonAdapter<Integer>(getActivity(), R.layout.item_currency_buluo, mDatas) {
            @Override
            public void convert(ViewHolder holder, Integer integer) {
                holder.setOnClickListener(R.id.afl_itemview, new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        startActivity(new Intent(getActivity(), PostBarActivity.class));
                    }
                });
            }
        });
    }

}
